import api from '@/api';
import { defineStore } from 'pinia';

export const useUserStore = defineStore('user', {
  state: () => ({
    token: '',
    id: '',
    name: '',
    role: '',
    avatar: '',
  }),
  actions: {
    async syncUser() {
      const data = await api.getUser();
      for (const key in data) {
        const element = data[key];
        this[key] = element;
      }
    },
  },
});
